package casa.depesos.app.com.http.req;


import java.util.Collections;
import java.util.List;
import java.util.Map;

import casa.depesos.app.com.http.HttpReq;
import casa.depesos.app.com.http.Req;
import casa.depesos.app.com.http.ReqCallback;
import casa.depesos.app.com.http.bean.MsgBean;
import casa.depesos.app.com.http.data.Msg;
import casa.depesos.app.com.http.parser.MsgParser;

public class MsgReq implements HttpReq<MsgBean> {
    String type;
    int count;

    public MsgReq(String type, int count) {
        this.type = type;
        this.count = count;
    }

    @Override
    public void req(ReqCallback<MsgBean> callback) {

    }

    @Override
    public Map getBody() {
        Map map = HttpReq.super.getBody();
        map.put("msgCategory", type);
        map.put("retCount", count + "");
        return map;
    }

    public List<Msg> req() {//  /app/msg/msgList
        try {
            MsgBean bean = Req.post("/app/communication/messageList", getParam(), getHeader(), getBody(), new MsgParser(), this);
            return bean.list;
        } catch (Throwable e) {
            e.printStackTrace();
            return Collections.emptyList();
        }
    }
}
